package cn.edu.nwsuaf.examcenter.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.edu.nwsuaf.examcenter.pojo.Manager;
import cn.edu.nwsuaf.examcenter.service.LoginService;

/*****
 * 
 * @author Fantacy
 * 
 */
@Controller
public class LoginController {
	@Resource(name="loginService")
	private LoginService loginService;
	
	/****
	 * 管理员登录
	 * @param manager
	 * @param session
	 * @param modelMap
	 * @return
	 */
	@RequestMapping(value="/login",method = RequestMethod.POST)
	public String login(@ModelAttribute Manager manager, HttpSession session,ModelMap modelMap){
		//session.setAttribute("str","hello");
		return loginService.loginManager(manager, session,modelMap);
	}
	
	/****
	 * 注销登录
	 * @param session
	 * @return
	 */
	@RequestMapping(value="/logout")
	public String logout(HttpSession session){
		session.removeAttribute("managers");
		return "login";
	}
	
	
}
